;(function () {
	
	'use strict';



	var isMobile = {
		Android: function() {
			return navigator.userAgent.match(/Android/i);
		},
			BlackBerry: function() {
			return navigator.userAgent.match(/BlackBerry/i);
		},
			iOS: function() {
			return navigator.userAgent.match(/iPhone|iPad|iPod/i);
		},
			Opera: function() {
			return navigator.userAgent.match(/Opera Mini/i);
		},
			Windows: function() {
			return navigator.userAgent.match(/IEMobile/i);
		},
			any: function() {
			return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
		}
	};

	var fullHeight = function() {

		if ( !isMobile.any() ) {
			$('.js-fullheight').css('height', $(window).height());
			$(window).resize(function(){
				$('.js-fullheight').css('height', $(window).height());
			});
		}

	};

	var centerBlock = function() {
		$('.aue-section-with-image .aue-box').css('margin-top', -($('.aue-section-with-image .aue-box').outerHeight()/2));
	  	$(window).resize(function(){
	  		$('.aue-section-with-image .aue-box').css('margin-top', -($('.aue-section-with-image .aue-box').outerHeight()/2));
	  	});
	};

	var responseHeight = function() {
		setTimeout(function(){
			$('.js-responsive > .v-align').css('height', $('.js-responsive > img').height());
		}, 1);
		
		$(window).resize(function(){
			setTimeout(function(){
				$('.js-responsive > .v-align').css('height', $('.js-responsive > img').height());
			}, 1);
		})
	};


	var mobileMenuOutsideClick = function() {

		$(document).click(function (e) {
	    var container = $("#aue-offcanvas, .js-aue-nav-toggle");
	    if (!container.is(e.target) && container.has(e.target).length === 0) {

	    	if ( $('body').hasClass('offcanvas-visible') ) {

    			$('body').removeClass('offcanvas-visible');
    			$('.js-aue-nav-toggle').removeClass('active');
				
	    	}
	    
	    	
	    }
		});

	};


	var offcanvasMenu = function() {
		$('body').prepend('<div id="aue-offcanvas" />');
		$('#aue-offcanvas').prepend('<ul id="aue-side-links">');
		$('#aue-header').prepend('<a href="#" class="js-aue-nav-toggle aue-nav-toggle"><i></i></a>');
		$('#aue-offcanvas').append($('.mob-nav').clone());
	};


	var burgerMenu = function() {

		$('body').on('click', '.js-aue-nav-toggle', function(event){
			var $this = $(this);

			$('body').toggleClass('aue-overflow offcanvas-visible');
			$this.toggleClass('active');
			event.preventDefault();

		});

		$(window).resize(function() {
			if ( $('body').hasClass('offcanvas-visible') ) {
		   	$('body').removeClass('offcanvas-visible');
		   	$('.js-aue-nav-toggle').removeClass('active');
		   }
		});

		$(window).scroll(function(){
			if ( $('body').hasClass('offcanvas-visible') ) {
		   	$('body').removeClass('offcanvas-visible');
		   	$('.js-aue-nav-toggle').removeClass('active');
		   }
		});

	};


	var toggleBtnColor = function() {
		if ( $('#aue-hero').length > 0 ) {	
			$('#aue-hero').waypoint( function( direction ) {
				if( direction === 'down' ) {
					$('.aue-nav-toggle').addClass('dark');
				}
			} , { offset: - $('#aue-hero').height() } );

			$('#aue-hero').waypoint( function( direction ) {
				if( direction === 'up' ) {
					$('.aue-nav-toggle').removeClass('dark');
				}
			} , { 
				offset:  function() { return -$(this.element).height() + 0; }
			} );
		}
	};



	
	$(function(){
		fullHeight();
		centerBlock();
		responseHeight()
		mobileMenuOutsideClick();
		offcanvasMenu();
		burgerMenu();
		toggleBtnColor();
		var swiper = new Swiper('.youLike .swiper-container', {
			pagination: '.swiper-pagination',
			paginationClickable: true,
			slidesPerView: 5,
			spaceBetween: 20,
			breakpoints: {
				1024: {
					slidesPerView: 4,
					spaceBetween: 20
				},
				768: {
					slidesPerView: 3,
					spaceBetween: 20
				},
				640: {
					slidesPerView: 2,
					spaceBetween: 20
				},
				320: {
					slidesPerView: 1,
					spaceBetween: 10
				}
			}
		});
	});


}());